Skip to content

Increase max AST depth and throw error if exceeded - #3250

Merged
orbitcowboy merged 1 commit into
cppcheck-opensource:mainfrom
keinflue:max-ast-depth
May 6, 2021
Merged

orbitcowboy merged 1 commit into
cppcheck-opensource:mainfrom
keinflue:max-ast-depth

Conversation

@keinflue

@keinflue keinflue commented May 6, 2021

Copy link
Copy Markdown
Contributor

While testing gzip's sources on my system, I got a an internalAstError saying AST broken, ternary operator missing operand(s).

It turns out that a file from gnulib exceeds the limit of AST_MAX_DEPTH, specifically float+.h has a macro with deeply nested ternary operators.

This PR doubles the value of AST_MAX_DEPTH and makes the code throw immediately with a clearer error message if it is exceeded instead of causing hard-to-follow errors down the line. If this behavior is not desired I would suggest at least maintaining a flag indicating whether the maximum depth was exceeded which can then be reported with other internalAstErrors to help diagnosis.

@danmar danmar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, can be merged when CI is happy..

@orbitcowboy
orbitcowboy merged commit c9a9b56 into cppcheck-opensource:main May 6, 2021
@keinflue
keinflue deleted the max-ast-depth branch May 8, 2021 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants